import request from "@/utils/request";

/**
 * 基金项目数据类型
 */
export interface FundProject {
  id: number | string;
  projectName: string;
  projectType: string;
  projectIntro: string;
  progressArray: string;
  raisedFund: number;
  targetFund: number;
  startDate: string;
  endDate: string;
  createTime: string;
  image?: string; // 项目图片
}

/**
 * 基金项目分页结果
 */
export interface FundProjectPageResult {
  list: FundProject[];
  total: number;
}

/**
 * 获取基金项目分页列表
 * @param pageNum 页码
 * @param pageSize 每页记录数
 * @param projectType 项目类型（可选）
 */
export function getFundProjectPage(
  pageNum: string | number,
  pageSize: string | number,
  projectType?: string
) {
  console.log(pageNum, pageSize, projectType);
  // 对于GET请求，uni.request会自动将data对象转为查询参数
  return request<FundProjectPageResult>({
    url: "/api/v1/fund-project/page",
    method: "GET",
    data: {
      pageNum,
      pageSize,
      projectType,
    },
  } as UniApp.RequestOptions);
}

/**
 * 获取三修基金项目表单数据
 * @param id 三修基金项目ID
 */
export function getFundProjectForm(id: number | string) {
  return request<FundProject>({
    url: `/api/v1/fund-project/${id}/form`,
    method: "GET",
  } as UniApp.RequestOptions);
}
